Smart pointer owning the object instance it encapsulates. More...
Public Member Functions | |
| UniquePtr () noexcept | |
| UniquePtr (T *data) noexcept | |
| template<typename U , typename = std::enable_if_t<std::is_base_of_v<T, U>>> | |
| UniquePtr (U *data) noexcept | |
| UniquePtr (const UniquePtr< T > &other)=delete | |
| UniquePtr (UniquePtr< T > &&other) noexcept | |
| template<typename U , typename = std::enable_if_t<std::is_base_of_v<T, U>>> | |
| UniquePtr (UniquePtr< U > &&other) noexcept | |
| ~UniquePtr () | |
| T * | get () const |
| bool | empty () const |
| T * | release () |
| void | reset (T *data=nullptr) |
| T & | operator* () |
| const T & | operator* () const |
| T * | operator-> () |
| const T * | operator-> () const |
| UniquePtr< T > & | operator= (const UniquePtr< T > &other)=delete |
| UniquePtr< T > & | operator= (UniquePtr< T > &&other) noexcept |
| operator bool () const | |
| bool | operator! () const |
| operator std::unique_ptr< T > () | |
| template<typename U , typename = std::enable_if_t<std::is_base_of_v<U, T>>> | |
| operator std::unique_ptr< U > () | |
| UniquePtr (std::unique_ptr< T > stdPtr) noexcept | |
| template<typename U , typename = std::enable_if_t<std::is_base_of_v<T, U>>> | |
| UniquePtr (std::unique_ptr< U > stdPtr) noexcept | |
Smart pointer owning the object instance it encapsulates.
Globally, this is an equivalent of an std::unique_ptr. However, the aim is not to replace the use of the standard unique pointer in client code, but rather offer a safe way to transfer them to the engine through the method arguments. Its use should be transparent and emulate the way a unique_ptr is normally used.
|
noexcept |
Empty constructor.
|
noexcept |
Raw pointer constructor.
| data | The pointer to take ownership of. |
|
noexcept |
Raw pointer constructor, enabled for classes / structures for which the template typename is a base of the passed pointer instance.
| data | The pointer to take ownership of. |
|
delete |
Copy constructor not allowed, as ownership cannot be shared.
| other |
|
noexcept |
Move constructor.
| other | The other pointer to move from. |
|
noexcept |
Move constructor, enabled for classes / structures for which the template typename is a base of the passed pointer instance.
| other | The other pointer to move from. |
| nkMemory::UniquePtr< T >::~UniquePtr | ( | ) |
Destructor.
|
noexcept |
Constructor from a standard unique_ptr implementation.
| stdPtr | The pointer to move over. |
|
noexcept |
Constructor from a standard unique_ptr implementation. Version enabled to support inheritance and conversion to a base type for the contained instance.
| stdPtr | The pointer to move over. |
| T* nkMemory::UniquePtr< T >::get | ( | ) | const |
| bool nkMemory::UniquePtr< T >::empty | ( | ) | const |
| T* nkMemory::UniquePtr< T >::release | ( | ) |
Releases the contained instance, along with its ownership, without deleting it.
| void nkMemory::UniquePtr< T >::reset | ( | T * | data = nullptr | ) |
Resets the held instance with the one provided as a parameter, deleting the old one in the process.
| data | The new pointer to the data to wrap. |
| T& nkMemory::UniquePtr< T >::operator* | ( | ) |
Star operator for direct access to the instance.
| const T& nkMemory::UniquePtr< T >::operator* | ( | ) | const |
Star operator for direct access to the instance, const version.
| T* nkMemory::UniquePtr< T >::operator-> | ( | ) |
Arrow operator for direct access to the instance.
| const T* nkMemory::UniquePtr< T >::operator-> | ( | ) | const |
Arrow operator for direct access to the instance, const version.
|
delete |
Copy assignment operator is unavailable, as ownership can't be shared.
| other |
|
noexcept |
Move assignment operator.
| other | The other pointer to copy from. |
| nkMemory::UniquePtr< T >::operator bool | ( | ) | const |
Bool conversion operator. Equivalent of the empty method, returning false if the pointer is nullptr, true otherwise.
| bool nkMemory::UniquePtr< T >::operator! | ( | ) | const |
Not operator, negating the bool conversion operator.
| nkMemory::UniquePtr< T >::operator std::unique_ptr< T > | ( | ) |
Conversion operator, to the standard unique_ptr implementation.
| nkMemory::UniquePtr< T >::operator std::unique_ptr< U > | ( | ) |
Conversion operator, to the standard unique_ptr implementation. Version enabled to support inheritance and conversion to a base type for the contained instance.